home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Miscellaneous / CopyPaste 3.3.4 / CopyPaste Tools Sourcecode / Tab to Spaces / Tab 2 Space.p next >
Encoding:
Text File  |  1997-06-06  |  1.8 KB  |  76 lines  |  [TEXT/CWIE]

  1. {•This sourcecode is an example for creating a FKey coderesource with•}
  2. {•Metrowerks Pascal. It is copyrighted by Peter Hoerster and released•}
  3. {•for free use in any Shareware or Freeware product as a way to thank all•}
  4. {•programmers who share code snippets. You may put this sources on any•}
  5. {•CD ROM or any Archive Server but you may not sell it. •}
  6.  
  7. {• For comments please write to <hoerster@muenster.de>•}
  8.  
  9. unit Tab2Spaces;
  10.  
  11. interface
  12.  
  13.     uses
  14.         Types, OSUtils, GestaltEqu, Script, notification, Resources, Events,
  15.          PascalA4, QuickDraw, ToolUtils, Memory, LowMem, Scrap;
  16.  
  17.  
  18.  
  19. {$MAIN}
  20.                         
  21.     procedure main;        
  22.  
  23. implementation
  24.  
  25.     procedure dopaste;
  26.     const
  27.         pastecode=2422;
  28.     var 
  29.         qel: EvQelPtr;
  30.     begin
  31.             if ppostevent(3, pastecode, qel) = noerr then
  32.             qel^.evtqmodifiers := cmdkey;
  33.     end;
  34.  
  35.     
  36.     
  37.     procedure main;
  38.         const
  39.             step = 1000;
  40.         var
  41.             oldA4: LongInt;
  42.             myerr: oserr;
  43.             myclipsize, templongint: longint;
  44.             myclipHandle: handle;
  45.             substhandle: Handle;
  46.             i: integer;
  47.             subst: str15;
  48.     begin
  49.         oldA4 := SetCurrentA4;
  50.         myclipsize := GetScrap(nil, 'TEXT', templongint);
  51.         mycliphandle := Tempnewhandle(myclipsize,myerr);
  52.         if myerr=noerr then 
  53.             begin
  54.                 myclipsize := GetScraP(myclipHandle, 'TEXT', templongint);
  55.                 if myclipsize > 0 then
  56.                     begin
  57.                         subst := '    ';
  58.                         substhandle := newhandle(4);
  59.                         blockmove(@subst[1], substhandle^, 4);
  60.                         subst := '1';
  61.                         subst[1] := char(ord(9));
  62.                         repeat
  63.                             i := ReplaceText(mycliphandle, substhandle, subst);
  64.                         until i = 0;
  65.                         myerr := ZeroScrap;
  66.                         myclipsize:=gethandlesize(mycliphandle);
  67.                         Temphlock(mycliphandle,myerr);
  68.                         myerr := putscrap(myclipsize, 'TEXT', myclipHandle^);
  69.                         Temphunlock(myCliphandle,myerr);
  70.                         dopaste;
  71.                     end;
  72.             end;
  73.         TempDisposeHandle(myCliphandle,myerr);
  74.         oldA4 := SetA4(oldA4);
  75.     end;
  76. end.